package com.binance.binancedemo.cell

import android.view.ViewGroup
import com.binance.binancedemo.R
import com.binance.binancedemo.entity.Ticker
import com.binance.binancedemo.recycler.BaseRecyclerCell
import com.binance.binancedemo.recycler.BaseRecyclerViewHolder

/**
 * Created by zhangkaiyu on 17/12/12.
 */
class TickerCell(ticker:Ticker) : BaseRecyclerCell<Ticker, BaseRecyclerViewHolder>(ticker) {

    override fun reloadResource() {
    }

    override fun releaseResource() {
    }

    override fun createViewHolder(parent: ViewGroup?): BaseRecyclerViewHolder =
            createHolderByLayout(R.layout.c_ticker, parent)

    override fun onBindViewHolder(viewHolder: BaseRecyclerViewHolder) {
        viewHolder.setBigDecimalText(R.id.tv_last_price, mData.lastPrice)
        viewHolder.setBigDecimalText(R.id.tv_price_change_percent, mData.priceChangePercent)
        viewHolder.setBigDecimalText(R.id.tv_volume, mData.volume)
        viewHolder.setBigDecimalText(R.id.tv_high_price, mData.highPrice)
        viewHolder.setBigDecimalText(R.id.tv_low_price, mData.lowPrice)
        viewHolder.setBigDecimalText(R.id.tv_ask_price, mData.askPrice)
        viewHolder.setBigDecimalText(R.id.tv_bid_price, mData.bidPrice)
        viewHolder.setBigDecimalText(R.id.tv_open_price, mData.openPrice)
        viewHolder.setBigDecimalText(R.id.tv_pre_close_price, mData.prevClosePrice)
        viewHolder.setBigDecimalText(R.id.tv_price_change, mData.priceChange)
    }

    override fun getType(): Int {
        return 1
    }
}

